<?php

$this->pageTitle = 'World map of publications';
$this->pageSummary = sprintf(
	'A world map of publications authored by \'%s\'.
	<p><em>Explanation:</em> This page shows a worldmap. The map highlights every country a publication of this person was published. This enrichment uses a link from the ST Publications dataset against the GeoNames dataset to retrieve the country initials.</p>',
	$this->author
);
$this->navigationMenu()->addDefaultItems();
$this->actionBar()->addAction('Back to publications of '. $this->author, sprintf($this->baseUrl('/page/author/%s/'), $this->author));
$this->actionBar()->addAction('Visual overview of publications', sprintf($this->baseUrl('/page/author/graph/%s/'), $this->author));
$this->actionBar()->addAction('Topics of author', sprintf($this->baseUrl('/page/author/topics/%s/'), $this->author));
$this->actionBar()->addAction('Visualization of co authors', sprintf($this->baseUrl('/page/author/coauthors/%s/'), $this->author));

$this->navigation()->findById('author_index')->setLabel($this->author);
$this->navigation()->findById('author_index')->setParams(array('queryparam'=>$this->author));

if(count($this->codes) == 0){
	echo 'No locations found';
}
else{

?>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>

<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAAptF_ImCpYQaAFALR5XMlxBReaja7GjqPWnWsKKfJMBtei8I4tBS5HVQlg3n_elCEJ6_YjgS28gqVJw"></script>
<script type='text/javascript'>
   google.load('visualization', '1', {'packages': ['geomap']});
   google.setOnLoadCallback(drawMap);

    function drawMap() {
		var data = new google.visualization.DataTable();
		data.addColumn('string', '', 'Country');
		data.addColumn('number', 'Number of publications', 'a');
		data.addRows(<?php echo count($this->codes)+1; ?>);

		<?php
		$i = 0;
		foreach($this->codes as $code => $freq){

			echo 'data.setValue('.$i.', 0, \''.$code.'\');'."\n";
			echo 'data.setValue('.$i.', 1, '.$freq.');'."\n";
			$i++;
		}
		echo 'data.setValue('.$i.', 0, \'AQ\');'."\n";
		echo 'data.setValue('.$i.', 1, 0);'."\n";
		?>
		var options = {};
        options['dataMode'] = 'regions';
	  
		var container = document.getElementById('visualization');
		var geomap = new google.visualization.GeoMap(container);
		geomap.draw(data, options);
  };
</script>
<?php
if(count($this->locations) > 0){
?>
<h2>Locations of publications</h2>
<div id="visualization" style="width: 600px; height: 350px;"></div>
<?php } 
}?>
  